package com.appcenter.application.mapper;


import com.appcenter.application.input.App.GetAppsInput;
import com.appcenter.application.model.Apps;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;

@org.apache.ibatis.annotations.Mapper
@Repository
public interface AppsMapper extends Mapper<Apps>{

    @Select("<script>" +
            "select * from apps where 1=1 " +
            "" +
            " <when test='keyword!=null'>" +
            " AND (AppCode like concat('%',#{keyword},'%') or AppCode like concat('%',#{keyword},'%'))" +
            " </when>" +
            "" +
            "</script>")
    public List<Apps> SearchApps(GetAppsInput input);



    @Select("select * from apps where AppCode=#{AppCode}")
    public List<Apps> GetAllAppsByAppCode(String AppCode);

    @Select("select * from apps where AppCode=#{AppCode} AND id <> #{NewId}")
    public List<Apps> GetAllAppsByAppCodeNoId(@Param("AppCode") String AppCode,@Param("NewId") String NewId);


    @Select("select * from apps where AppName=#{AppName}")
    public List<Apps> GetAllAppsByAppName(String AppName);

    @Select("select * from apps where AppName=#{AppName} AND id <> #{NewId}")
    public List<Apps> GetAllAppsByAppNameNoId(@Param("AppName") String AppName,@Param("NewId") String NewId);
}
